<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('app', 'Articles');
$this->params['breadcrumbs'][] = $this->title;
$arr_cat = \common\models\Category::get(0,\common\utils\Com::cats());
?>
<div class="article-index">

    <h1><?= Html::encode($this->title) ?></h1>

    <p>
        <?= Html::a(Yii::t('app', '新文章'), ['create'], ['class' => 'btn btn-success']) ?>
        <?= Html::a(Yii::t('app', '创建文章分类'), ['/category/create'], ['class' => 'btn btn-success']) ?>
    </p>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'id',

            [
                'attribute' => 'cat',
                'value' => function($data) {
                    return $data['cats']['name'];
                },
                'filter' => $arr_cat,
            ],
            'title',
//            'keyword',
//            'info',

            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>
</div>
